package com.bby.screentool.views;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatImageButton;

import com.bby.screentool.R;

public class AudioButton extends AppCompatImageButton {
    public AudioButton(@NonNull Context context) {
        super(context);
    }

    public AudioButton(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public AudioButton(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    // rtc连接后显示
    public void setShow(Boolean show) {
        setEnabled(show);
        setVisibility(show? VISIBLE:INVISIBLE);
    }

    public void setOpen(Boolean open) {
        setImageDrawable(getDrawable(open? R.drawable.ic_voice_fill:R.drawable.ic_voice_close_fill));
    }

    @SuppressLint("UseCompatLoadingForDrawables")
    private Drawable getDrawable(int id) {
        return getResources().getDrawable(id, getContext().getTheme());
    }

}